public class Goods {
    // 定义数组存储3个商品对象。
    //商品的属性：商品的id，名字，价格，库存。
    //创建三个商品对象，并把商品对象存入到数组当中。
    private int id;
    private String name;
    private int price;
    private int stock;

    public Goods() {
    }

    public Goods(int id, String name, int price, int stock) {

        this.id = id;
        this.name = name;
        this.price = price;
        this.stock = stock;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getPrice() {
        return price;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public int getStock() {
        return stock;
    }

    public void setId(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static void main(String[] args) {
        //创建三个商品对象，并把商品对象存入到数组当中。
        Goods te1 = new Goods(001, "HuaWei", 5999, 100);
        Goods te2 = new Goods(002, "XiaoMi", 3999, 100);
        Goods te3 = new Goods(003, "Vivo", 2999, 100);

        //定义数组存储3个商品对象。
        Goods[] array = {te1, te2, te3};

        //遍历数组，打印每个商品对象的属性。
        for (int i = 0; i < 3; i++) {
            Goods t = array[i];
            System.out.println("商品ID：" + t.getId() + "\t" + "商品名字：" + t.getName() +
                    "\t" + "商品价格：" + t.getPrice() + "\t" + "商品库存：" + t.getStock() + "\t");


        }


    }
}
